﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BtoBSWT315.User
{
    public partial class Upgrade : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] == null)
            {
                Response.Redirect("../Default.aspx");
            }
        }

        protected void submit_Click(object sender, EventArgs e)
        {
            
            if (string.IsNullOrEmpty(company.Text) || String.IsNullOrEmpty(linkman.Text) || String.IsNullOrEmpty(phone.Text))
            {
                Response.Write("<script>alert('带*号的为必填项，请按要求填写!');</script>");
                Response.Write("<script>history.go(-1);</script>");
                Response.End();
            }

            else
            {
                Admin.Admin_ClassDb classdb = new Admin.Admin_ClassDb();

                string user = Session["user"].ToString();
                //添加时间
                string insertSql = "insert into Upgrade (loginuser,company,linkman,phone,email,qq,msn,[content],dateandtime )values ('" + user + "','" + company.Text.Trim() + "','" + linkman.Text.Trim() + "','" + phone.Text.Trim() + "','" + email.Text.Trim() + "','" + QQ.Text.Trim() + "','" + msn.Text.Trim() + "','" + content.Text.Trim() + "','" + DateTime.Now.ToShortDateString() + "')";

                if (classdb.GetNonResult(insertSql) != 0)
                {
                    Response.Redirect("Pay.aspx");
                }
                else
                {
                    Response.Write("<script>alert('操作失败！请重新填写。');</script>");
                    Response.Write("<script>history.go(-1);</script>");
                    Response.End();
                }
            }
        }
    }
}